﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Timers;
using Modele;
using Guitar.Vues;

namespace Guitar.Modules.Manche
{
    /// <summary>
    /// Logique d'interaction pour Corde.xaml
    /// </summary>
    public partial class MiniatureNote : Label
    {
        public bool isActived = false;
        public Note note;

        public MiniatureNote()
        {
            InitializeComponent();
        }

        public MiniatureNote(String name)
        {
            InitializeComponent();                 
            Content = name;
            
        }



        private void Miniature_MouseEnter(object sender, MouseEventArgs e)
        {
            Background = (Brush)FindResource("over");
            if (!isActived)
            {
                Opacity = 0.7;

            }

        }

        private void Miniature_MouseLeave(object sender, MouseEventArgs e)
        {
            Background = (Brush)FindResource("normal");
            if (!isActived)
            {
                Opacity = 0;

            }

        }

        private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (isActived)
            {
                isActived = false;
                Opacity = 0.0;

            }
            else
            {
                isActived = true;
                Opacity = 1;

                App.lecteur.Lire(note);

                /* on ajoute une note l à la partition selectionnée si il existe une mesure */            
                if (App.MesureSelected!=-1){

                //on ajoute la note au modele
                    Note tmp=note.Copy();
                App.Partitions[App.PartitionEnCours].pistes[App.PisteEnCours].mesures[App.MesureSelected].noteListe.Add(note.Copy());


                //On ajoute la note sur la partition classique
                ((VueMesure)App.Pages[App.ModeleurEnCours].VuePiste.Children[App.MesureSelected]).AjouterNoteClassique(tmp);

                //On ajoute la note sur la tab
                ((VueMesure)App.Pages[App.ModeleurEnCours].VuePiste.Children[App.MesureSelected]).AjouterNoteTab(tmp, false);

                }
                
            }

        }
       


    }
}
